/**
 * 
 */
package neptune.manager.validator.rules.topology;

import neptune.manager.model.topology.Topology;
import neptune.manager.utils.Logger.LogContext;
import neptune.manager.utils.Logger.MessageType;
import neptune.manager.validator.ValidatorResult;
import neptune.manager.validator.ValidatorRule;
import neptune.manager.validator.Validator.Status;

/**
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 * 
 */
public class TopologyNameRule extends ValidatorRule<Topology> {

	@Override
	public String getName() {
		return "NameValidator";
	}

	@Override
	protected ValidatorResult validationAlgorithm(Topology toValidate,
			ValidatorResult result) {

		result.setStatus(Status.VALID);
		LogContext log = result.getLog();

		if (toValidate.getName() == null || toValidate.getName().equals("")) {
			result.setStatus(Status.ERROR);
			log.addMessage("The topology name is undefined", MessageType.ERROR);
		}

		return result;
	}

}
